<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>    
<%@ page import="org.swim.entity.User" %>
<%@ page import="org.swim.entity.AddAbilityRequest" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Ability Requests</title>
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
	<%@ include file="NavBar.jsp" %>
	<% 
	User user = (User) session.getAttribute("user"); 
	%>
	<div class="container">
	<% if (user.isAdmin()) {	
		boolean areThereAbilitiesRequests = (Boolean) request.getAttribute("areThereAbilitiesRequests");
	%>	
		<h1>Ability Requests</h1>
		<% if (areThereAbilitiesRequests) { 
		List<AddAbilityRequest> abilitiesRequests = (List<AddAbilityRequest>) request.getAttribute("abilitiesRequests");  
		if(!(abilitiesRequests.size()==0)) {
			for (AddAbilityRequest current: abilitiesRequests) { %>
			<div class="row">
				<div class="span4">
					<div class="media"><a class="pull-left" href="<% out.print("Profile?id="+ current.getMittente().getId());%>">
						<img class="media-object" alt="64x64" style="width: 64px; height: 64px;" src="<% out.print(current.getMittente().getAvatar()); %>"  data-src="holder.js/64x64">
						<div class="media-body">		
					    <h4 class="media-heading"><% out.print(current.getMittente().getNome() + " " + current.getMittente().getCognome()); %></h4>	
					    </div></a>
				    	<p><br /><strong>Ability: </strong><% out.print(current.getAbilita().getNome()); %></p>
				    </div>
				</div>
			    <div class="span4">
				    <p>
					 	<a href="ApproveAbilityRequest?id=<% out.print(current.getIdRichiesta()); %>"><button class="btn btn-small btn-success" type="button">Approve</button></a>
					  	<a href="DenyAbilityRequest?id=<% out.print(current.getIdRichiesta()); %>"><button class="btn btn-small btn-danger" type="button">Deny</button></a>
					</p>
				</div>
		    </div>	
		    <% } %>
		<% } else { %>
		<div class="alert alert-info"><strong>No abilities requests:</strong> there are no ability requests to approve</div>	
	<% } } else { %>
		<div class="alert alert-info"><strong>No abilities requests:</strong> there are no ability requests to approve</div>	
	<% } } else { %>	
	<%@ include file="NoRights.jsp" %>
	<% } %>
	</div>
</body>
</html>